package com.training.java.core.homework07.collections.laptop.pre15;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ListDemo {

	public static void main(String[] args) {
		
		// Created two classes LaptopMutable and Television. My goal is to show
		// List can contain any objects of any class. First doing LaptopMutable.
		
		// Instantiating 3 specific LaptopMutable objects below.
		LaptopMutable laptop1 = new LaptopMutable("laptop1");
		LaptopMutable laptop2 = new LaptopMutable("laptop2");
		LaptopMutable laptop3 = new LaptopMutable("laptop3");
		System.out.println("");

		// Instantiating List
		List list1 = new ArrayList();
		
		list1.add(laptop1);
		list1.add(laptop2);
		list1.add(laptop3);
		
		// Read from list
		Iterator ite = list1.iterator();
		
		while(ite.hasNext())
		{
			LaptopMutable laptop = (LaptopMutable) ite.next();
			System.out.println("");
			System.out.println("Details of " + laptop.getLaptopName());
			System.out.println("------------------");
			System.out.println("Memory = " + laptop.getMemory());
			System.out.println("Disk Capacity = " + laptop.getDiskCapacity());
		}
		
		System.out.println("");
		System.out.println("");
		System.out.println("");
		System.out.println("");
		
		// Instantiating 3 specific Television objects below.
		Television television1 = new Television("television1");
		Television television2 = new Television("television2");
		Television television3 = new Television("television3");
		System.out.println("");

		// Instantiating List
		List list2 = new ArrayList();
		
		list2.add(television1);
		list2.add(television2);
		list2.add(television3);
		
		// Read from list
		Iterator ite2 = list2.iterator();
		
		while(ite2.hasNext())
		{
			Television television = (Television) ite2.next();
			System.out.println("");
			System.out.println("Details of " + television.getTelevisionName());
			System.out.println("----------------------");
			System.out.println("Volume = " + television.getVolume());
		}
	}
}
